﻿import static org.junit.Assert.*;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
public class testFunction
{
	Function TestF = new Function( ) ;
    @Before
    public void setUp( )
    {
    	TestF = new Function( );
    	System.out.println( "testFunction" ) ;
    }
    @After
    public void tearDown( )
    {
    	TestF = null ;
    }
    @Test
    public void testGcd( ) 
    {
        int expected = 15 ;
        int result = TestF.gcd( 75 , 120 ) ;
        assertEquals( expected , result ) ;
    }
    @Test
    public void testSum( ) 
    {
        int expected = 195 ;
        int result = TestF.sum( 75 , 120 ) ;
        assertEquals( expected , result ) ;
    }
    @Test
    public void testDif( ) 
    {
        int expected = -45 ;
        int result = TestF.dif( 75 , 120 ) ;
        assertEquals( expected , result ) ;
    }
    @Test
    public void testPrime( ) 
    {
        int expected = 1 ;
        int result = TestF.isprime( 97 ) ;
        assertEquals( expected , result ) ;
    }
    @Test		
    public void testCheckName( )		
    {		
    	String TestName [ ] = new String[ ] { "123" , "1234567890" , "abcdefghijk" , "123.12" , "a12_=<_>" } ;		
        int    expected [ ] = new int[ ] { 1 , 1 , 0 , 0 , 0 } ;		
        int      result ;		
        result = TestF.CheckNameOK( TestName[ 0 ] ) ;		
      	assertEquals( expected[ 0 ] , result ) ;		
      	result = TestF.CheckNameOK( TestName[ 1 ] ) ;		
       	assertEquals( expected[ 1 ] , result ) ;		
      	result = TestF.CheckNameOK( TestName[ 2 ] ) ;		
       	assertEquals( expected[ 2 ] , result ) ;		
       	result = TestF.CheckNameOK( TestName[ 3 ] ) ;		
       	assertEquals( expected[ 3 ] , result ) ;		
       	result = TestF.CheckNameOK( TestName[ 4 ] ) ;		
       	assertEquals( expected[ 4 ] , result ) ;		
    }		
    @Test		
    public void testBMI( )		
    {		
    	int expected = 22 ;		
        int result = TestF.GetBMI( 58 , 162 ) ;		
        assertEquals( expected , result ) ;		
    }		
    	
} 
